.text
.global main

main:
	# 1) call BIOS print string "It's bootblock!"
	 la		$a0, 	msg
	 ld		$t2,	printstr
	 jalr	$t2 
	 
	
	# 2) call BIOS read kernel in SD card
	 li		$a0, 	0xffffffffa0800000
	 li		$a1, 	512
	# li		$a2,	512
	 lh		$a2,	0xffffffffa08001fe
	 dmul	$a2, $a2, 512
	 li		$ra,	0xffffffffa0800000
	 ld		$t2, 	read_sd_card
	 jr		$t2

	# 3) jump to kernel
	 #ld		$t2,	kernel_main
	 #jr		$t2					
	 

# 4) while(1) --> stop here
# L1:
#	 j 		L1

.data

msg: .ascii "It's a bootloader...\n"

# 1. PMON read SD card function address
# read_sd_card();
read_sd_card: .dword 0xffffffff8f0d5e10

# 2. PMON print string function address
# printstr(char *string)
printstr: .dword 0xffffffff8f0d5534

# 3. PMON print char function address
# printch(char ch)
printch: .dword 0xffffffff8f0d5570

# 4. kernel address (move kernel to here ~)
kernel : .dword 0xffffffffa0800000

# 5. kernel main address (jmp here to start kernel main!)
kernel_main : .dword 0xffffffffa0800200
